package com.common.util;

import java.lang.Character.UnicodeBlock;

public class LangUtils {

	private LangUtils() {}

	public static boolean isChinese(String str) {
		char[] charArray = str.toCharArray();

		for (char c : charArray) {
			if (Character.UnicodeBlock.of(c) != UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS) {
				return false;
			}
		}

		return true;
	}

	public static boolean containsChinese(String str) {
		char[] charArray = str.toCharArray();

		for (char c : charArray) {
			if (Character.UnicodeBlock.of(c) == UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS) {
				return true;
			}
		}

		return false;
	}

	public static void main(String[] args) {
		System.out.println(isChinese("we're together!"));
		System.out.println(isChinese("我们在一起!"));

		System.out.println(containsChinese("we're together!"));
		System.out.println(containsChinese("我们在一起!"));
	}

}
